package main

import (
	"fmt"
	"gorm-study/src/pkg/student/models"
	"gorm-study/src/pkg/utils/dbutil"
)

func main() {

	rows, _ := dbutil.DB.Model(&models.Student{}).Select("age, count(0) as num").Group("age").Having("count(0) > ?", 1).Rows()
	defer rows.Close()
	for rows.Next() {
		var age int
		var num int
		rows.Scan(&age, &num)
		fmt.Printf("age:%v, num:%v \n", age, num)
	}
}
